package com.streamer.app.adapter

import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.streamer.app.bean.LiveBean
import com.streamer.app.fragment.ChatFragment
import com.streamer.app.fragment.UsersFragment
import com.streamer.app.fragment.PPTWhiteboardFragment
import com.streamer.app.fragment.WhiteboardFragment

class ThreePanePagerAdapter(
    private val activity: AppCompatActivity,
    private val mliveData: LiveBean?
) : FragmentStateAdapter(activity) {
    override fun getItemCount(): Int = 3
    override fun createFragment(position: Int): Fragment = when (position) {
        0 -> WhiteboardFragment.Companion.newInstance(mliveData)
        1 -> ChatFragment.Companion.newInstance(mliveData)
        else -> {
            val roomId = activity.intent?.getStringExtra("roomId") ?: ""
            UsersFragment.Companion.newInstance(roomId, mliveData)
        }
    }
}